#./thirdparty/libmariadb/Makefile
SOURCES =   libmariadb/ma_alloc.c \
            libmariadb/ma_array.c \
            libmariadb/ma_charset.c \
			libmariadb/ma_client_plugin.c \
			libmariadb/ma_compress.c \
			libmariadb/ma_context.c \
			libmariadb/ma_default.c \
			libmariadb/ma_dtoa.c \
			libmariadb/ma_errmsg.c \
			libmariadb/ma_hash.c \
			libmariadb/ma_init.c \
			libmariadb/ma_io.c \
			libmariadb/ma_list.c \
			libmariadb/ma_ll2str.c \
			libmariadb/ma_loaddata.c \
			libmariadb/ma_net.c \
			libmariadb/ma_password.c \
			libmariadb/ma_pvio.c \
			libmariadb/ma_sha1.c \
			libmariadb/ma_stmt_codec.c \
			libmariadb/ma_string.c \
			libmariadb/ma_time.c \
			libmariadb/ma_tls.c \
			libmariadb/mariadb_async.c \
			libmariadb/mariadb_charset.c \
			libmariadb/mariadb_dyncol.c \
			libmariadb/mariadb_lib.c \
			libmariadb/mariadb_rpl.c \
			libmariadb/mariadb_stmt.c
OBJS = $(patsubst %.c,%.o,$(notdir $(SOURCES)))
OBJSD = $(addprefix $(TMP_DIR)libmariadb/,$(OBJS))

OBJS2 = my_auth.o old_password.o pvio_socket.o openssl.o
OBJSD2 = $(addprefix $(TMP_DIR)libmariadb/,$(OBJS2))

INCLUDE = -DDBUG_OFF -DHAVE_COMPRESS -DLIBMARIADB -DTHREAD -DHAVE_POLL -DHAVE_SYS_SOCKET_H -DHAVE_SYS_SELECT_H -DHAVE_TLS \
-I ./ -I ./include -I ./libmariadb -I ./plugins/pvio -I ./plugins/auth -I ../zlib

all:chkdir libmariadb$(TAGTYPE)

chkdir:
	$(shell mkdir -p $(TMP_DIR)libmariadb/)

libmariadb_static:$(OBJS) $(OBJS2)
	$(AR) $(OUT_DIR)libmariadb.a $(OBJSD) $(OBJSD2)

libmariadb_shared:$(OBJS) $(OBJS2)
	$(CC) -shared -fPIC $(OBJSD) $(OBJSD2) -o $(OUT_DIR)libmariadb.so

$(OBJS):%.o:libmariadb/%.c
	$(CC) $(INCLUDE) $(CFLAGS) -c $< -o $(TMP_DIR)libmariadb/$@

my_auth.o:plugins/auth/my_auth.c
	$(CC) $(INCLUDE) $(CFLAGS) -c plugins/auth/my_auth.c -o $(TMP_DIR)libmariadb/my_auth.o
old_password.o:plugins/auth/old_password.c
	$(CC) $(INCLUDE) $(CFLAGS) -c plugins/auth/old_password.c -o $(TMP_DIR)libmariadb/old_password.o
pvio_socket.o:plugins/pvio/pvio_socket.c
	$(CC) $(INCLUDE) $(CFLAGS) -c plugins/pvio/pvio_socket.c -o $(TMP_DIR)libmariadb/pvio_socket.o
openssl.o:libmariadb/secure/openssl.c
	$(CC) $(INCLUDE) $(CFLAGS) -c libmariadb/secure/openssl.c -o $(TMP_DIR)libmariadb/openssl.o

clean:
	rm -rf $(TMP_DIR)libmariadb/*.o
